package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_UserGradeRecord 用户积分记录
 *
 */
public class TestData_TB_UserGradeRecord
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_UserGradeRecord saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_User user
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_UserGradeRecord");
		return (TB_UserGradeRecord)repository.save(newMust(
				user
			));
	}
	
	public static TB_UserGradeRecord newMust(
		bairui.international.model.domain.jpa.TB_User user
	){
		return new TB_UserGradeRecord(new TB_UserGradeRecord.MustProperties() {
			/** 积分 */
			@Override public Double getScore(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
			}
			/** 用户 */
			@Override public bairui.international.model.domain.jpa.TB_User getUser(){
				return user;
			}
			/** 类型 */
			@Override public bairui.international.model.type.Type_UserGrade getType(){
				return bairui.international.model.type.Type_UserGrade.OrderBuy;
			}
			/** 当前积分 */
			@Override public Double getCurrentScore(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_UserGradeRecord saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_User user
	,bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_UserGradeRecord");
		return (TB_UserGradeRecord)repository.save(newAll(
				user
				,productOrder
			));
	}
	
	public static TB_UserGradeRecord newAll(
		bairui.international.model.domain.jpa.TB_User user
	,bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		return new TB_UserGradeRecord(
			new TB_UserGradeRecord.MustProperties() {
				/** 积分 */
				@Override public Double getScore(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
				}
				/** 用户 */
				@Override public bairui.international.model.domain.jpa.TB_User getUser(){
					return user;
				}
				/** 类型 */
				@Override public bairui.international.model.type.Type_UserGrade getType(){
					return bairui.international.model.type.Type_UserGrade.OrderBuy;
				}
				/** 当前积分 */
				@Override public Double getCurrentScore(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
				}
			},
			new TB_UserGradeRecord.OptionalSingleProperties() {
				/** 产品订单 */
				@Override public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder(){
					return productOrder;
				}
				/** 产品订单状态 */
				@Override public bairui.international.model.status.State_ProductOrder getState(){
					return bairui.international.model.status.State_ProductOrder.Sending;
				}
			}
		);
	}
	

}
